package com.yaorange.common.enums;

public enum YesOrNoEnum {
    YES("是", 1),
    NO("否", 0);
    final String name;
    final int code;
    public String getName() {
        return name;
    }
    public long getCode() {
        return code;
    }
    YesOrNoEnum(String name, int code) {
        this.name = name;
        this.code = code;
    }
    /**
     * 匹配枚举值
     *
     * @param name 名称
     * @return YesOrNoEnum
     */
    public static YesOrNoEnum of(String name) {
        if (name == null) {
            return null;
        }
        YesOrNoEnum[] values = YesOrNoEnum.values();
        for (YesOrNoEnum yesOrNoEnum : values) {
            if (yesOrNoEnum.name.equals(name)) {
                return yesOrNoEnum;
            }
        }
        return null;
    }
}
